#ifndef DETECTORWIDGET_H
#define DETECTORWIDGET_H

#include <QWidget>
#include "detectorinterface.h"
#include "detector_global.h"
class DetectorObject;

namespace Ui {
class DetectorWidget;
}

class DetectorWidget : public QWidget, public DetectorInterface
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID DetectorPlugin_iid)
    Q_INTERFACES(DetectorInterface)
public:
    explicit DetectorWidget(QWidget *parent = 0);
    ~DetectorWidget();

    QObject *getObject() { return this; }
    bool getDetectorConfig(DetectorConfig &config) const;
    void setDetectorHook(DetectorProc proc, void *userData) { m_proc = proc; m_userData = userData; }
    ushort *getImage(ushort *&img, int &width, int &height);
    void startCapture(bool start);

signals:
    void initDetector();
    void freeDetector();

protected slots:
    void onDeviceStatus(DetectorState state, const QString &msg);

private slots:
    void on_endBtn_clicked();

private:
    void init();

    Ui::DetectorWidget *ui;
    DetectorObject *d;
    QThread *t;
    DetectorProc m_proc;
    void *m_userData;
};

#endif // DETECTORWIDGET_H
